package com.zufe.khw;

import java.util.TreeSet;

public class TestModel {
    public static void main(String[] args) {
        Student s1 = new Student("张三", 20, 90, 80, 70);
        Student s2 = new Student("李四", 21, 80, 70, 60);
        Student s3 = new Student("王五", 22, 70, 60, 50);
        Student s4 = new Student("赵六", 23, 60, 50, 40);
        Student s5 = new Student("孙七", 24, 20, 40, 30);
        Student s6 = new Student("周八", 25, 40, 30, 20);
        TreeSet<Student> set = new TreeSet<>((o1,o2) -> {
            int sum1 = o1.getChineseScore() + o1.getMathScore() + o1.getEnglishScore();
            int sum2 = o2.getChineseScore() + o2.getMathScore() + o2.getEnglishScore();
            int i = sum1 - sum2;
            i = i == 0 ? o1.getChineseScore() - o2.getChineseScore() : i;
            i = i == 0 ? o1.getMathScore() - o2.getMathScore() : i;
            i = i == 0 ? o1.getAge() - o2.getAge() : i;
            i = i == 0 ? o1.getName().compareTo(o2.getName()) : i;
            return i;
        });
        set.add(s1);
        set.add(s2);
        set.add(s3);
        set.add(s4);
        set.add(s5);
        set.add(s6);
        for (Student o : set) {
            System.out.println(o);
        }
    }
}
